<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>生活缴费</title>

  <link rel="stylesheet" href="../static/../static/framework/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="../static/../static/framework/reset.css">
  <link rel="stylesheet" href="../static/../static/css/footer.css">
  <link rel="stylesheet" href="../static/../static/css/editRecipient.css">
  <link href="../static/layui-v2.9.1/layui/css/layui.css" rel="stylesheet">
  <script src="../static/layui-v2.9.1/layui/layui.js"></script>
  <link rel="stylesheet" href="../static/bootstrap-5.3.0-dist/css/bootstrap.min.css">
  <script src="../static/bootstrap-5.3.0-dist/js/bootstrap.bundle.min.js"></script>
  <link rel="stylesheet" href="../static/css/recipientList.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="../static/mods/layarea.js"></script>

  <style>
    .search-form {
      display: flex;
      align-items: center;
      max-width: 600px;
      margin: 20px auto;
      border: 1px solid #ccc;
      border-radius: 4px;
      overflow: hidden;
      background-color: #fff;
      box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    }

    /* 输入框样式 */
    .search-form input[type="text"] {
      flex: 1;
      padding: 10px;
      font-size: 16px;
      border: none;
      outline: none;
    }

    /* 按钮样式 */
    .search-form button {
      padding: 10px 20px;
      background-color: #4CAF50;
      color: white;
      border: none;
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    .search-form button:hover {
      background-color: #45a049;
    }

    /* 标签样式 */
    .search-form label {
      padding: 10px;
      background-color: #4CAF50;
      color: white;
      font-weight: bold;
      border-right: 1px solid #ccc;
    }

    .layui-form-item {
      border: 1px solid #e6e6e6;
      /* 设置边框样式 */
      padding: 10px;
      /* 可选的内边距 */
      margin-bottom: 10px;
      /* 可选的下边距 */
    }

    .layui-form-label {
      width: auto;
      /* 或根据实际需要设置固定宽度 */
      padding-right: 10px;
      /* 可选的右内边距 */
      text-align: right;
      /* 可选的文本对齐方式 */
    }

    .layui-input-inline {
      margin-right: 10px;
      /* 可选的右外边距 */
    }

    .select-wrapper {
      width: 200px;
      /* 控制选择框宽度 */
      display: inline-block;
      /* 行内块元素 */
    }

    .recipientList {
      list-style-type: none;
      padding: 0;
    }

    .recipientList li {
      display: flex;
      align-items: center;
      justify-content: space-between;
      border-bottom: 1px solid #ccc;
      padding: 20px;
      border-radius: 10px;
      transition: background-color 0.3s ease;
      /* 添加过渡效果 */
    }

    .recipientList li:hover {
      background-color: #f0f0f0;
      /* 鼠标悬停时的背景色 */
    }


    .recipient h3 {
      margin: 0;
      font-size: 18px;
      color: #333;
    }

    .recipient p {
      margin: 5px 0 0;
      color: #666;
    }

    .fa-angle-right {
      cursor: pointer;
      color: #007bff;
      background-color: #fafafa;
    }

    .fa-angle-right:hover {
      color: #0056b3;
    }
  </style>


</head>

<body>
<div class="wrapper">
  <header style="display: flex;">
    <i class="fa fa-angle-left fa-2x" onclick="location.href='/pay'" style="font-size: 20px">返回</i>
    <p style="margin: auto;">生活缴费</p>
    <p style="margin-right: 46.84px;"></p>
  </header>
  <br><br>

  <form action="/company/search" method="get" class="search-form">
    <label for="search"><img src="../static/img/搜索 .png" width="20px" height="20px"></label>
    <input type="text" id="search" name="search" placeholder="请输入公司名称...">
    <button type="submit">搜索</button>
  </form>


  <form class="layui-form" style="background-color: white;padding: 20px;" action="/company/companies" method="get">
    <div class="layui-form-item" id="area-picker">
      <div class="layui-form-label">地址：</div>
      <div class="layui-input-inline" style="width: 200px;">
        <select name="province" class="province-selector" data-value="河南省" lay-filter="province-1">
          <option value="">请选择省</option>
        </select>
      </div>
      <div class="layui-input-inline" style="width: 200px;">
        <select name="city" class="city-selector" data-value="郑州市" lay-filter="city-1">
          <option value="">请选择市</option>
        </select>
      </div>
      <!-- <div class="layui-input-inline" style="width: 200px;">
        <select name="county" class="county-selector" data-value="龙岗区" lay-filter="county-1">
          <option value="">请选择区</option>
        </select>
      </div> -->
      <button type="submit" class="layui-btn layui-btn-normal" style="margin-left: 40%;;">提交</button>
    </div>
    <!-- <div style="display: flex; justify-content: center;">
      <button type="submit" class="layui-btn layui-btn-normal" id="submitBtn">提交</button>
    </div> -->
  </form>

  <ul class="recipientList" style="margin-top: 10px">
    <li class="recipient" th:each="company : ${session.companies}">
      <div>
        <h3 th:text="${company.companyCount}">623***803</h3>
        <p th:text="${company.companyName}">李四</p>
      </div>
      <form action="/payment" method="get">
        <input type="hidden" name="companyCount" th:value="${company.companyCount}">
        <button class="fa fa-angle-right fa-2x" type="submit" style="font-size: 100%;border: none;">缴费</button>
      </form>
    </li>

  </ul>

  <br>
  <br>

  <footer class="footer">
    <div>
      <button type="button" class="layui-btn">
        <i class="layui-icon layui-icon-left"></i>
      </button>
      <button type="button" class="layui-btn">
        <i class="layui-icon layui-icon-right"></i>
      </button>
    </div>
  </footer>

</div>


<script>
  const back = document.querySelector('button:first-child')
  const forword = back.nextElementSibling
  back.addEventListener('click', function () {
    //history.back()
    history.go(-1)
  })

  forword.addEventListener('click', function () {
    //history.forward()
    history.go(1)
  })
  //配置插件目录
  layui.config({
    base: './mods/'
    , version: '1.0'
  });
  //一般直接写在一个js文件中
  layui.use(['layer', 'form', 'layarea'], function () {
    var layer = layui.layer
            , form = layui.form
            , layarea = layui.layarea;

    layarea.render({
      elem: '#area-picker',
      change: function (res) {
        //选择结果
        console.log(res);
      }
    });
  });

  $(document).ready(function () {
    $('#submitBtn').on('click', function () {
      var province = $('.province-selector').val();
      var city = $('.city-selector').val();

      // 假设后端接口为 '/submit-data'
      $.ajax({
        url: '/user/main',
        method: 'POST',
        data: {
          province: province,
          city: city
        },
        success: function (response) {
          // 处理成功响应
          console.log('数据提交成功');
          // 可以根据后端返回的数据执行进一步的操作
        },
        error: function (xhr, status, error) {
          // 处理错误情况
          console.error('数据提交失败:', error);
        }
      });
    });
  });
</script>
</body>

</html>